1. Field of the Invention
The present invention relates to a Z buffer hidden surface removal device (HSRD), and more particularly to a hidden surface removal device that uses the depth information (Z data) of an object drawn in a three-dimensional or two-dimensional image display device to perform hidden surface removal by a Z buffer.
2. Description of the Related Art
A conventional graphic engine usually has a frame buffer and a Z buffer. The frame buffer serves as a memory for holding the digital expressions of the color and brightness of each pixel within an image, such as a dynamic random access memory (DRAM) or a static random access memory (SRAM). The Z buffer serves as a memory for holding a numeral for each pixel within the frame buffer. The numeral stored in this Z buffer is called Z data or a Z value and is depth information representative of the distance between an observer and an object displayed with pixels. Smaller Z data indicates that the object is closer to the observer.
As shown in FIG. 5, a conventional Z buffer HSRD comprises an input-output portion 1 for performing input-output of data such as a Z value, a counter value, and an address, with the outside, a Z buffer portion 2 for storing a Z value, and a Z operation circuit portion 6 for inputting the Z value and outputting a write control signal and an operation result.
Next, the operation of this conventional Z buffer HSRD will be described along the flowchart of FIG. 6.
By the Z operation circuit portion 6, two data of Z data (Zs) and a write address (Adr) are read out from the input-output portion 1 (step S101). By the Z operation circuit portion 6, Z data (Zd) being currently stored in an address (Adr) within the Z buffer portion 2 is taken out of the Z buffer portion 2 (step S102). The Z data (Zs) from the input-output portion 1 and the Z data (Zd) taken out of the Z buffer portion 2 are compared (step S103). When the Z data (Zs) is smaller (step S104), i.e., when a desired pixel is on the side closer to the observer, a "1" is output as a write control signal (step S105). This write control signal is also used in the writing to the Z buffer portion 2, and in the case of "1,"the Z data (Zs) from the input-output portion 1 is written to the position of the address (Adr) of the Z buffer portion 2 (step S106). Also, when it is determined in the step S104 that Zd is smaller than Zs, a "0" is output as a write control signal (step S107), and in this case, nothing is written to the Z buffer portion 2.
The above-described operation is performed for each of Z data that are desired to be written.
FIGS. 7A to 7C show ideal hidden surface removal processes. In the figures, the right direction represents a Z-axis direction and the arrow represents a direction in which an observer is seeing. FIG. 7A shows data written first, and FIG. 7B shows data that is newly written with respect to the first data. FIG. 7C shows a result in which ideal hidden surface removal was accomplished by overlapping two pixel data. Thus, only pixels close to the view point of the observer remain.
FIGS. 8A to 8C show the results obtained as data was written in the same method as a write method of normal memories. In normal writing, data is always overwritten. If data is written over the first data of FIG. 8A, the result will become as shown in FIG. 8B. As a result, since data written later always remains as shown in FIG. 8C, consequently, hidden surface removal will not be performed correctly.
FIGS. 9A to 9C show the processes of removing a hidden surface by a conventional Z buffer method. If data to be written is laid over the data of FIG. 9A, the result will become as shown in FIG. 9B. If greater Z data is not written like the crosshatched pixels of FIG. 9B or if it is overwritten by other Z data, then it does not remain in the Z buffer. Among Z data finally written in all addresses of the Z buffer, the smallest data remains as shown in FIG. 9C.
The hidden surface removal is performed in this way, and what is output from the conventional Z buffer HSRD is a write control signal representative of the possibility and impossibility of writing for each data, and Z data that finally remained within the Z buffer.
However, the Z data of the above-described HSRD is insufficient in applications such as virtual reality in which an image of high picture quality needs to be generated with real time.
FIG. 10A illustrates the sun appearing from behind the cloud and the glow generated around it. When you see a very light object with your naked eyes, the light passing through the eyelashes is diffracted and radial rays generate around the object.
The drawing method of the sun and the cloud will hereinafter be described.
First an image of the cloud is drawn with a certain Z value, as shown in FIG. 10B, and then an image of the sun is drawn with a greater Z value than that, as shown in FIG. 10C. Finally an image of the glow is drawn with a Z value smaller than the cloud. When ideal hidden surface removal is performed, there is no possibility that a pixel being in a longer distance is written over a pixel being in a shorter distance, so there is no possibility that the image of the sun is written over the image of the cloud. Therefore, a result like FIG. 10C is obtained. Incidentally, it is preferable that for reality, the glow of the sun change according to the lightness of the sun. The lightness of the sun can be approximated with constant times the visual field area of the sun not hidden by other object, i.e., the uncovered visual field area of the sun. The uncovered visual field area can be obtained in the process of the hidden surface removal. First, all objects that can become an obstacle are drawn, and finally the image of the sun is drawn. If the number of pixels that were hidden-surface removed is subtracted from the number of pixels of the image of the sun, the number of uncovered pixels of the sun will be obtained.
The hidden surface removal is performed as described above, but what is output from the conventional Z buffer HSRD was binary data indicating that the pixel having the Z value can be drawn to the frame buffer or the pixel having the Z value cannot be drawn to the frame buffer.
However, when the above-described HSRD is used in applications such as virtual reality in which there is the need of generating an image of high picture quality with real time, the device having only binary information is often insufficient.
FIGS. 11A, 11B and FIGS. 12A and 12B are examples of the case where binary hidden surface removal is insufficient.
FIGS. 11A and 11B which are a first example is a case where an object whose outline is dim and which projects from a wall is drawn. In this case, as shown in FIG. 11A, it is preferable that the object be drawn so that it becomes transparent as it comes closer to the wall. However, when hidden surface removal is performed with only binary information, a boundary line between the object and the wall, indicated by the arrow of FIG. 11B, becomes clear and the dim feeling of the object disappears.
FIGS. 12A and 12B which are a second example is a case where an object projecting from muddy water is drawn. In this case, as shown in FIG. 12A, it is preferable that the water around the object projecting from muddy water be transparent. However, when hidden surface removal is performed with only binary information, a boundary line between the object and the wall becomes clear and the transparent feeling of water disappears, as shown in FIG. 12B.
As described above, when the image of the sun is sufficiently large, it can be used as an uncovered visual field area of the sun, but since the conventional Z buffer HSRD outputs only a write control signal representative of the possibility or impossibility of writing for each data, and Z data that finally remained in the Z buffer, the above-described number of uncovered visual field pixels and number of pixels to be drawn could not be provided to an observer. Therefore, the number of uncovered visual field pixels and the number of pixels to be drawn, which are used when the lightness of the sun appearing from behind the cloud is calculated, cannot be output.
Also, since the conventional HSRD outputs a result of a Z operation only as binary data indicating that a pixel with the Z value can be drawn to the frame buffer or a pixel with the Z value cannot be drawn to the frame buffer, sufficient information cannot be provided when an object whose lightness changes according to the distance and thickness is drawn.